{extend name="base"}
{block name="content"}
		<script type="text/javascript">
	    $(function(){
	    	$(".status").click(function(){
		        $this=$(this);
	            var data=$(this).attr("data"),src=$(this).attr("src");
	            var dataArr=data.split("|"),table=dataArr[0],colum=dataArr[1],key=dataArr[2],keyval=dataArr[3];
	            var newval=src.indexOf("btn_enable.png")>0?0:1;
		        $.ajax({
		            type:"post",
		            dataType:"json",
		            url:"{:url('Stores/ajaxdata')}",
		            data:{"table":table,"colum":colum,"columval":newval,"key":key,"keyval":keyval},
		            beforeSend:function(obj){
		                $this.attr("src","/data/assets/images/btn_loading.gif");
		            },
		            success:function(data){
		            	if(data.code==1){
		            		if(src.indexOf("btn_enable.png")>0){
		            			$this.attr("src","/data/assets/images/btn_disable.gif");
		            		}else{
		            			$this.attr("src","/data/assets/images/btn_enable.png");
		            		}
		            	}else{
		            		alert(data.msg);
		            	}
		            	
		            }
		        });
		    });
	    });
	    </script>
		<div class="wrap">
		<ul class="nav nav-tabs">
			<li class="active"><a>插件市场</a></li>
		</ul>
		<form method="post" class="js-ajax-form">
			<table class="table table-hover table-bordered">
				<thead>
					<tr>
						<th align="center">ID</th>
						<th>插件名（标识）（版本）</th>
						<th>插件图片</th>
						<th>插件类型</th>
						<th>插件演示地址</th>
						<th>添加时间</th>
						<th>插件要求版本</th>
						<th>插件发布人（用户名与ID）</th>
						<th>插件下载地址</th>
						<th>下载次数</th>
						<th>是否热门</th>
						<th>是否审核</th>
						<th align="center">操作</th>
					</tr>
				</thead>
				<tbody>
					{empty name="list"}
					<tr><td colspan="12">没有数据</td></tr>
					{else/}
					{volist name="list" id="vo"}
					<tr>
						<td align="center">{$vo.id}</td>
						<td>{$vo.title}({$vo.key})({$vo.version})</td>
						<td>{empty name="vo.thumb"}--{else/}<img src="{$vo.thumb}" style="width: 100px; height: auto;" />{/empty}</td>
						<td>
							{if condition="$vo.type eq 'behavior'"}行为插件
							{elseif condition="$vo.type eq 'module'"/}模块插件
							{elseif condition="$vo.type eq 'behavior_module'"/}行为模块插件
							{else/}
							{/if}
						</td>
						<td>{$vo.demourl}</td>
						<td>{$vo.datetime|date='Y-m-d H:i:s'}</td>
						<td>{$vo.require_op}{$vo.require_ver}</td>
						<td>{$vo.nickname}({$vo.uid})</td>
						<td>{$vo.down_url}</td>
						<td>{$vo.down_time}</td>
						<td>
							{eq name="vo.is_hot" value="1"}
                        	<img src="/data/assets/images/btn_enable.png" class="status" data="Store|is_hot|id|{$vo.id}"/>
                        	{else/}
                        	<img src="/data/assets/images/btn_disable.gif" class="status" data="Store|is_hot|id|{$vo.id}"/>
                        	{/eq}
						</td>
						<td>
							{eq name="vo.is_check" value="1"}
                        	<img src="/data/assets/images/btn_enable.png" class="status" data="Store|is_check|id|{$vo.id}"/>
                        	{else/}
                        	<img src="/data/assets/images/btn_disable.gif" class="status" data="Store|is_check|id|{$vo.id}"/>
                        	{/eq}
						</td>

						<td align="center">
							
							{eq name="vo.is_delete" value="1"}
							<a href="{:url('Stores/recovery',['id'=>$vo.id])}" class="js-ajax-dialog-btn" data-msg="您确定要启用此用户吗？">恢复数据</a> |
							已删除
							{else/}
							{if condition="$vo.is_check eq 4"}
							已拒绝
							{elseif condition="$vo.is_check eq 0"/}
							<a href="{:url('Stores/refuse',['id'=>$vo.id])}" class="js-ajax-dialog-btn_alert" data-msg="您确定要拉黑此用户吗？">审核不通过</a>|
							{else/}

							{/if}
							<a href="{:url('Stores/delStore',['id'=>$vo.id])}" class="js-ajax-dialog-btn" data-msg="您确定要启用此用户吗？">删除</a>
							{/eq}
						</td>
					</tr>
					{/volist}
					{/empty}
				</tbody>
			</table>
			<div class="pagination">{$list->render()}</div>
		</form>
	</div>
		<script src="__THEMES__/js/common.js"></script>
		<script type="text/javascript">
		$(function(){
			Wind.use('artDialog', function () {
            $('.js-ajax-dialog-btn_alert').on('click', function (e) {
                e.preventDefault();
                var $_this = this,
                    $this = $($_this),
                    href = $this.data('href'),
                    msg = $this.data('msg');
                href = href?href:$this.attr('href');
                if(!msg){
                	msg="您确定要进行此操作吗？";
                }

                art.dialog({
					title: '请输入你拒绝的理由',
					content: '<input id="reason" placeholder="拒绝理由" value=""/>',
					ok: function () {
						var reason = $('#reason').val();
						this.close(reason);
						$.getJSON(href,{"reason":reason}).done(function (data) {
                            console.log(data);
                            if (data.code == 0) {
                                if (data.url) {
                                    location.href = data.url;
                                } else {
                                	art.dialog({   
    									content: data.msg,
    									icon: 'succeed',
    									ok: function () {   
    										reloadPage(window);
    										return true;
    									},
    									
    								}); 
                                }
                            } else if (data.code == -1) {
                                //art.dialog.alert(data.info);
								art.dialog({   
									content: data.msg,
									icon: 'warning',
									ok: function () {   
										this.title(data.msg);   
										return true;   
									}
								}); 
                            }else{
                               art.dialog({   
                                    content: data.msg,
                                    icon: 'warning',
                                    ok: function () {   
                                        this.title(data.msg);   
                                        return true;   
                                    }
                                });  
                            }
                        });
					}
				});
        	});
        	});
		});
		</script>
{/block}